package com.randao.manage.firstPage.controller;

import com.randao.api.firstPage.HousesTestApi;
import com.randao.framework.model.domain.entity.JsonResult;
import com.randao.framework.model.domain.house.Houses;
import com.randao.manage.firstPage.service.HousesTestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author： ~Mr·Weng~
 * @CreateTime： 2019年-04月-24日  1:16
 * Look at the wine in the glass toast the rich first.
 */
@RestController
@RequestMapping("/houseTest")
public class HousesTestController implements HousesTestApi {

    @Autowired
    private HousesTestService housesTestService;

    @Override
    @GetMapping("/findByHid")
    public ResponseEntity<JsonResult> findByHid(String id) {
        int hid = Integer.parseInt(id);
        JsonResult jr = null;
        try {
            Houses houses = housesTestService.findByHid(hid);
            jr = new JsonResult(houses, "查询成功", true, 10000);
        } catch (Exception e) {
            e.printStackTrace();
            jr = new JsonResult(e.getClass().getName() + ":" + e.getMessage(), "查询失败", false, 11111);
        }

        return ResponseEntity.ok(jr);
    }


}
